#define _CRT_SECURE_NO_WARNINGS
#include "Binary.h"

void test1() {
	char arr[] = "ABD##E#H##CF##G##";
	int i = 0;
	BTNode* root = BinaryTreeCreate(arr, &i);
	BinaryTreePrevOrder(root);
	int num = BinaryTreeLeafSize(root);
	printf("num=%d\n", num);
	int num1 =  BinaryTreeSize(root);
	printf("num1=%d\n", num1);
	int num2 =  BinaryTreeLevelKSize(root,3);
	printf("num2=%d\n", num2);
	BTNode* node =  BinaryTreeFind(root, 'H');
	printf("node=%c\n", node->_data);

	BinaryTreeLevelOrder(root);
	BinaryTreeDestory(&root);
	BinaryTreePrevOrder(root);
	
	
}
BTNode* BuyBTNode(BTDataType x)
{
	BTNode* node = (BTNode*)malloc(sizeof(BTNode));
	if (node == NULL)
	{
		perror("malloc fail");
		exit(-1);
	}

	node->_data = x;
	node->_left = node->_right = NULL;
	return node;
}
void test2() {
	BTNode* n1 = BuyBTNode(1);
	BTNode* n2 = BuyBTNode(2);
	BTNode* n3 = BuyBTNode(3);
	BTNode* n4 = BuyBTNode(4);
	BTNode* n5 = BuyBTNode(5);
	BTNode* n6 = BuyBTNode(6);

	BTNode* n7 = BuyBTNode(7);
	n2->_right = n7;

	n1->_left = n2;
	n1->_right = n4;
	n2->_left = n3;
	n4->_left = n5;
	n4->_right = n6;
	printf("%d\n", BinaryTreeComplete(n1));

	BinaryTreeDestory(&n1);
}
int main() {
	test2();

	return 0;
}